package org.or5e.service.core.ds;

import org.or5e.service.core.ds.login.LoginDataSource;
import org.or5e.service.core.dao.UserLogin;

public class DataSourceTest {
	public static void main(String[] args)throws InterruptedException {
		System.out.print("Getting Data Source.");
		DataSourceFactory dFactory = DataSourceFactory.getDataSourceFactory();
		System.out.println("Done "+dFactory);
		
		System.out.print("Getting Login Data Source.");
		LoginDataSource loginDataSource = (LoginDataSource)dFactory.getDataSource(LoginDataSource.class);
		System.out.println("Done. "+loginDataSource);
		
		System.out.print("Initlized the Data Source. ");
		loginDataSource.initilizeDataSource();
		System.out.println("Done. ");
		
		System.out.println(loginDataSource.isSessionActive("Test"));
		
		UserLogin login = new UserLogin();
		login.setLoginID("mylife.ponraj@gmail.com");
		login.setPassword("demo");
		String sessionID = loginDataSource.authenticateUser(login );
		System.out.println("Session ID :"+sessionID);
		
		System.out.println(loginDataSource.isSessionActive(sessionID));
		Thread.sleep(10000);
		System.out.println(loginDataSource.isSessionActive(sessionID));
			
		loginDataSource.closeDataSource();
	}
}
